From: Matthew Barnes Date: Fri, 16 Jan 2015 15:04:18 +0000 (-0500) Subject: Add ostree_ensure_repo_writable() X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~831 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7941189dfde3795fb649aba41e207f0072dfcd86;p=ostree.git Add ostree_ensure_repo_writable() Commands that need to write files within the repo directory can call this early to ensure the directory is writable for the current user. If not, it fails with a helpful "You need to be root to perform this command" message. --- diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index c48a03c5..94d29ca6 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -360,3 +360,17 @@ ostree_admin_option_context_parse (GOptionContext *context, out: return success; } + +gboolean +ostree_ensure_repo_writable (OstreeRepo *repo, + GError **error) +{ + gboolean ret; + + ret = ostree_repo_is_writable (repo, error); + + g_prefix_error (error, "Cannot write to repository: "); + + return ret; +} + diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h index 5f31b240..659727f3 100644 --- a/src/ostree/ot-main.h +++ b/src/ostree/ot-main.h @@ -51,3 +51,5 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context, int *argc, char ***argv, OstreeSysroot **out_sysroot, GCancellable *cancellable, GError **error); + +gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);